<?php

ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_NOTICE);
header("Content-type: text/html; charset=utf-8");

require_once 'lib/upload/UploadFile.php';

use lib\upload\UploadFile;

//取文件后缀名
function extname($str){
	return substr(strtolower(strrchr($str,'.')), 1);
}
	

$action = isset($_GET["action"]) ? addslashes($_GET["action"]) : "";
	
if($action == "upload"){

	try{
		$uf = new UploadFile($_FILES["upfile"], 1024*1024*2, [".apk"]);
	}catch(RuntimeException $re){
		exit(json_encode(["code"=>-1, "info"=> $re->getMessage()], JSON_UNESCAPED_UNICODE));
	}

	if(!$uf->mvRandName("/data/apk", 30)){
		exit(json_encode(["code"=>-4, "info"=> "文件移动失败"], JSON_UNESCAPED_UNICODE));
	}

	exit;
	
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP上传文件</title>
</head>
<body>

<form enctype="multipart/form-data" action="upload.php?action=upload" method="POST">
  <input id="upfile" name="upfile" type="file" />
  <input type="submit" value="修改" name="submit" class="uu">
</form>

<script language="javascript">


</script>
</body>
</html>

